package d5_jdk8_time;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class Test9 {
    public static void main(String[] args) {
            // 本地日期时间对象
            LocalDateTime today = LocalDateTime.now();
            System.out.println(today);

            LocalDateTime birthDate = LocalDateTime.of(2001,12,10,20,00);
            System.out.println(birthDate);

            System.out.println("相差的年数：" + ChronoUnit.YEARS.between(birthDate,today));
            System.out.println("相差的月数：" + ChronoUnit.MONTHS.between(birthDate,today));
            System.out.println("相差的周数：" + ChronoUnit.WEEKS.between(birthDate, today));
            System.out.println("相差的天数：" + ChronoUnit.DAYS.between(birthDate,today));
            System.out.println("相差的时数：" + ChronoUnit.HOURS.between(birthDate,today));
            System.out.println("相差的分数：" + ChronoUnit.MINUTES.between(birthDate,today));
            System.out.println("相差的秒数：" + ChronoUnit.SECONDS.between(birthDate,today));
            System.out.println("相差的毫秒数：" + ChronoUnit.MILLIS.between(birthDate,today));
            System.out.println("相差的微秒数：" + ChronoUnit.MICROS.between(birthDate,today));
            System.out.println("相差的纳秒数：" + ChronoUnit.NANOS.between(birthDate,today));
    }
}
